package com.aidex.biz.service.impl;

import com.aidex.biz.domain.Appointment;
import com.aidex.biz.mapper.AppointmentMapper;
import com.aidex.biz.service.AppointmentService;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.common.utils.NumberUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 上门预约Service业务层处理
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-10-11
 */
@Service
@Transactional(readOnly = true)
public class AppointmentServiceImpl extends BaseServiceImpl<AppointmentMapper, Appointment> implements AppointmentService {
    private static final Logger log = LoggerFactory.getLogger(AppointmentServiceImpl.class);

    /**
     * 获取单条数据
     *
     * @param appointment 上门预约
     * @return 上门预约
     */
    @Override
    public Appointment get(Appointment appointment) {
        Appointment dto = super.get(appointment);
        return dto;
    }

    /**
     * 获取单条数据
     *
     * @param id 上门预约id
     * @return 上门预约
     */
    @Override
    public Appointment get(String id) {
        Appointment dto = super.get(id);
        return dto;
    }


    /**
     * 查询上门预约列表
     *
     * @param appointment 上门预约
     * @return 上门预约
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public List<Appointment> findList(Appointment appointment) {
        return super.findList(appointment);
    }

    /**
     * 分页查询上门预约列表
     *
     * @param appointment 上门预约
     * @return 上门预约
     */
    @Override
    @DataScope(userAlias = "a", deptAlias = "a")
    public PageInfo<Appointment> findPage(Appointment appointment) {
        return super.findPage(appointment);
    }

    /**
     * 保存上门预约
     *
     * @param appointment
     * @return 结果
     */
    @Override
    public boolean save(Appointment appointment) {
        return super.save(appointment);
    }


    /**
     * 删除上门预约信息
     *
     * @param appointment
     * @return 结果
     */
    @Override
    public boolean remove(Appointment appointment) {
        return super.remove(appointment);
    }

    /**
     * 批量删除上门预约
     *
     * @param ids 需要删除的上门预约ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteAppointmentByIds(String[] ids) {
        return mapper.deleteAppointmentByIds(ids);
    }

    /**
     * 获取最大编号
     *
     * @param appointment 上门预约
     * @return 结果
     */
    @Override
    public int findMaxSort(Appointment appointment) {
        return NumberUtils.nextOrder(mapper.findMaxSort(appointment));
    }

    @Override
    public Appointment findOneByStatus() {
        return mapper.findOneByStatus();
    }
}
